<template>
  <div id="mask">
    <div class="container">
      <h2 v-if="mineVictory" class="victory">游戏胜利</h2>
      <h2 v-if="!mineVictory" class="loser">输了个精光</h2>
      <div class="score">
        <p>胜利者: {{victory?'地主':'农民'}}</p >
        <p v-for="item in victoryer">{{item.name}}</p>
      </div>
      <div class="result" :class="{ 'text-red': text === '你赢了', 'text-green': text === '你输了' }">
        {{ text }}
      </div>
      <div class="buttons">
        <button class="btn back-btn" @click="gameOver">返回房间</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Victory",
  props: {
    victory: false,
    victoryer: [],
    mineVictory: false
  },
  data() {
    return {
      scores: {
        player1: 0,
        player2: 0,
        player3: 0
      },
      text: ''
    };
  },
  methods: {
    gameOver(){
      this.$emit("gameOver");
    }
  }
};
</script>

<style scoped>
.victory{
  color: #ad6105; /* 设置文本颜色 */
  text-shadow:
      -1px -1px 0 #000,
      1px -1px 0 #000,
      -1px 1px 0 #000,
      1px 1px 0 #000; /* 这里设置描边的颜色和位置 */
}
.loser{
  color: #8d7e6f; /* 设置文本颜色 */
  text-shadow:
      -1px -1px 0 #000,
      1px -1px 0 #000,
      -1px 1px 0 #000,
      1px 1px 0 #000; /* 这里设置描边的颜色和位置 */
}
#mask{
  position: absolute;
  width: 100vw;
  height: 100vh;
  left: 0;
  top: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  animation-name: showView;
  animation-duration: 1s;
  animation-iteration-count: infinite;
}
.container {
  text-align: center;
  padding: 20px;
  padding-left: 50px;
  padding-right: 50px;
  border-radius: 10px;
  background: rgba(254,254,254,0.7);
}
@keyframes showView {
  0%{
    opacity: 1;
  }
  100%{
    opacity: 1;
  }
}

.score {
  margin-bottom: 20px;
}

.result {
  font-size: 24px;
  margin-bottom: 20px;
}

.text-red {
  color: red;
}

.text-green {
  color: green;
}

.buttons {
  margin-top: 20px;
}

.btn {
  padding: 10px 20px;
  font-size: 16px;
  border: none;
  border-radius: 5px;
  background-color: #007BFF;
  color: #fff;
  cursor: pointer;
}

.btn:hover {
  background-color: #0056b3;
}

.restart-btn {
  margin-right: 20px;
}
</style>
